/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package models.negocio;

import config.LogErro;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;
import models.dados.JdbcDAO;
import models.entidades.TabAux;
import teste.utilitario.GerarSQL;
import teste.utilitario.ManipulaHash;

/**
 *
 * @author Wenderson
 */
public class JdbcTabAuxiliar extends JdbcDAO {
    
    private static PreparedStatement ps;
    private static ResultSet rs;

    public ResultSet resultadoChave(TabAux tabAux, HashMap<String, String> chavesReferenciadas) {
        try {
            StringBuilder sb = new StringBuilder("");
            //TODO: sb.append(GerarSQL.select(ManipulaHash.list(chavesReferenciadas, true)));
            sb.append("SELECT ");
            
            for (String chaveAux : chavesReferenciadas.keySet()) {
                sb.append(chaveAux)
                .append(", ");
            }
            
            String str = sb.substring(0, sb.length() - 2);
            sb = new StringBuilder(str);
            
            //TODO: System.out.println("FROM AQUI");
            sb.append(" FROM ")
            .append(tabAux.getEsquema())
            .append(".")
            .append(tabAux.getNome());
            
            return executeSQL(sb.toString());
            
        } catch (Exception e) {
            LogErro.gravaErro(e);e.printStackTrace();
        }
        return null;
    }
    
    
}
